package cn.broadsense.system.service.impl;

import cn.broadsense.system.domain.SysNotice;
import cn.broadsense.system.domain.SysUserNotice;
import cn.broadsense.system.mapper.SysUserNoticeMapper;
import cn.broadsense.system.service.ISysUserNoticeService;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * @author huangjinshi
 * @description
 * @createDate 2023-09-14 12:22:04
 */
@Service
public class SysUserNoticeServiceImpl extends ServiceImpl<SysUserNoticeMapper, SysUserNotice> implements ISysUserNoticeService {


    @Override
    public SysUserNotice getByUserIdAndNoticeId(Long userId, Long noticeId) {
        LambdaQueryWrapper<SysUserNotice> queryWrapper = Wrappers.lambdaQuery();
        queryWrapper.eq(SysUserNotice::getUserId, userId);
        queryWrapper.eq(SysUserNotice::getNoticeId, noticeId);
        queryWrapper.last("limit 1");
        return this.baseMapper.selectOne(queryWrapper);
    }
}
